import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';

const envrc = {
    test: {
        terser: false,
        output: {
            format: 'es',
            path: 'dist',
        }
    },
    prod: {
        terser: true,
        output: {
            format: 'es',
            path: 'dist',
        }
    }
}

const env = envrc[process.env.APP_MODE];

console.log(env);

export default {
    input: ['src/index.js', 'src/about.js', 'src/download/download.js'], // 支持多个入口文件
    output: {
        dir: 'dist', // 输出目录
        format: 'es',
        entryFileNames: '[name]/index.js', // 输出文件名模板
    },
    plugins: [
        resolve(),
        commonjs(),
        babel({
            exclude: 'node_modules/**'
        }),
        env.terser && terser()
    ]
};
